/**
 * Copyright(C) 2008 Matthias Braunhofer
 * All rights reserved
 *
 * Created on: 02.09.2008
 */

package it.cums.model;

import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Date;

public class Invoice {
	private ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
	private int id;
	private Date dueDate;
	private double amount;
	private String condition;
	private String type;
	private String status;
	private Date paymentDate;
	private Order order;
	
	public final static String[] CONDITIONS = {"At sight", "Net 30 days", "Net 60 days"};
    public final static String[] TYPES = {"Cash", "Bank transfer", "Draft"};
    public final static String[] STATUS = {"Open", "Received"};
    
	public Invoice() {		
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
		notifyListeners();
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
		notifyListeners();
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
		notifyListeners();
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
		notifyListeners();
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
		notifyListeners();
	}

	public Date getPaymentDate() {
		return paymentDate;
	}

	public void setPaymentDate(Date paymentDate) {
		this.paymentDate = paymentDate;
		notifyListeners();
	}
	
	public void setOrder(Order order) {
		this.order = order;
	}
	
	public Order getOrder() {
		return order;
	}
	
	public String toString() {
		return "Invoice " +  id;
	}
	
	private void notifyListeners() {
		for (PropertyChangeListener listener : listeners) {
			listener.propertyChange(null);
		}
	}
	
	public void setPropertyChangeListeners(ArrayList<PropertyChangeListener> listeners) {
		this.listeners = listeners;
	}
}
